<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #box {
            width: 500px;
            height: 500px;
            background-color: darkturquoise;
            border: 10px solid black;
        }

        #content {
            width: 200px;
            height: 200px;
            background-color: saddlebrown;
            padding: 60px;
            border: 10px solid black;
            position: relative;
            left: 30px;
            top: 30px;
        }
    </style>
</head>
<body>
<div id="box">
    <div id="content">

    </div>
    <script>
        var content = document.getElementById('content');
        //offset 如果 父元素中有定位元素
        //都是相对于上一个定位元素(position不为static)定位.
        //如果没有定位的元素,是相对于屏幕的
        //offset这种属性,它是只读的,不能改变

        console.log(content.offsetLeft);
        console.log(content.offsetTop);
        content.style.left='200px'
    </script>

</div>
</body>
</html>